<?php $this->load->view('header'); ?>
<?php
if ($msg = $this->session->flashdata('flash_message')) {
   //showMessage($msg['type'], $msg['msg']);
?>
    <script type="text/javascript">
        $.notify(
            "<?php echo $msg['msg']?>", 
            { 
               position:"top center",
                showAnimation: 'slideDown',
                autoHideDelay: 2000,
                className: 'success',
                hideAnimation: 'slideUp',
                autoHide: true,
                autoHideDelay: 3000
            }
        );
    </script>
<?php
}
?>

<div class="wrap-detail-project wrap-dashboard">
    <div class="container container-dashboard">
        <div class="row">
            <div class="col-lg-9 col-md-9 col-sm-9 col-xs-12 no-padding">
                <ul class="tab-dashboard">
                    <li class="active"><a href=""><?php echo $this->lang->line("Hire")?></a></li>
                    <li><a href=""><?php echo $this->lang->line("Manage")?></a></li>
                    <li><a href="<?php echo url_buyerEditProfile()?>"><?php echo $this->lang->line("Setting")?></a></li>
                </ul>
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12 no-padding">
                <div class="search-dashboard">
                    <form action="" method="post" id="frm-search">
                        <select name="search_type" class="search-type">
                            <option><?php echo $this->lang->line('Freelancers')?></option>
                            <option><?php echo $this->lang->line('Jobs')?></option>
                        </select>
                        <input type="text" name="search" class="search" placeholder="<?php echo $this->lang->line('Find freelancers');?>">
                        <button type="submit" class="btn-search glyphicon glyphicon-search"></button>
                    </form>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding">
                <ul class="nav nav-pills tab-child">
                    <li><a href="<?php echo site_url('buyer/viewMyProjects');?>"><?php echo $this->lang->line("My jobs")?></a></li>
                    <li><a href="<?php echo site_url('buyer/savedFreelancers');?>"><?php echo $this->lang->line("Saved freelancers")?></a></li>
                    <li class="active"><a href="<?php echo site_url('buyer/messages');?>"><?php echo $this->lang->line("Messages")?></a></li>
                    <li><a href=""><?php echo $this->lang->line("All updates")?></a></li>
                </ul>
            </div>
        </div>
        <div class="row app-panel messaged">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding app-panel-title">
                    <div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 padding-right">
                        <a href="<?php echo site_url('buyer/createMessage'); ?>" class="btn btn-post-job"><?php echo $this->lang->line('New message')?></a>
                    </div>
                    <div class="col-lg-10 col-md-10 col-sm-10 col-xs-9 no-padding">
                        <form action="" method="post">
                            <input type="text" name="search_job" class="form-control form-input" placeholder="<?php echo $this->lang->line('Search Messages')?>">
                            <button type="submit" class="btn-search glyphicon glyphicon-search"></button>
                        </form>
                    </div>
                </div>
                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 no-padding col-left">
                    <ul class="nav menu-message" role="tablist">
                        <li class="active">
                            <a href="#inbox" role="tab" data-toggle="tab"><?php echo $this->lang->line('Inbox')?>
                                <?php echo ($count_unread->num_rows() > 0)?' (<span id="count_unread">'.$count_unread->num_rows().'</span>)':''?>
                            </a>
                        </li>
                        <li>
                            <a href="#send" role="tab" data-toggle="tab"><?php echo $this->lang->line('Send')?>
                                <?php echo ($count_message_send->num_rows() > 0)?' (<span id="count_send">'.$count_message_send->num_rows().'</span>)':''?>
                            </a>
                        </li>
                        <li>
                            <a href="#archive" role="tab" data-toggle="tab"><?php echo $this->lang->line('Archive')?>
                                <?php echo ($count_archive->num_rows() > 0)?' (<span id="count_archive">'.$count_archive->num_rows().'</span>)':''?>
                            </a>
                        </li>
                    </ul>
                </div>
                <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 padding-left tab-content">
                    <?php
                    if($msg = $this->session->flashdata('flash_message'))
                    {
                        showMessage2($msg);
                    }
                    ?>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding message-content tab-pane fade active in" id="inbox">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding message-title">
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
                                <input type="checkbox" class="checkall">
                            </div>
                            <div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 no-padding">
                                <label class="mark-mess" data-type="1"><?php echo $this->lang->line('Mark as read')?></label>
                                <label class="mark-mess" data-type="0"><?php echo $this->lang->line('Mark as unread')?></label>
                                <label class="mark-mess" data-type="2"><?php echo $this->lang->line('Archive')?></label>
                            </div>
                        </div>
                        <div id="message_inbox">
                            <?php
                            if($message_inbox->num_rows() > 0) {
                                foreach ($message_inbox->result() as $item) {
                                    ?>
                                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding item-mess">
                                        <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
                                            <div class="table-cell">
                                                <input type="checkbox" class="checkbox" data-id="<?php echo $item->id; ?>">
                                            </div>
                                        </div>
                                        <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 no-padding">
                                            <a href="#" />
                                            <img src="<?php echo ( (is_file_exists($item->logo)) && ($item->logo != "")) ? uimage_url($item->logo) : image_default();?>" class="img-responsive" />
                                            </a>
                                        </div>
                                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                                            <div class="table-cell">
                                                <a href="#" ><?php echo $item->user_name; ?></a>

                                                <?php
                                                if($item->num_message > 1){
                                                echo ' <span>('.$item->num_message.')</span>';
                                                }
                                                ?>
                                                <p><?php echo dateAgo($item->created, 'd-m-Y') ?></p>
                                            </div>
                                        </div>
                                        <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7">
                                            <div class="table-cell">
                                                <span class="subject-message"><?php echo $item->subject ?></span>
                                                <p><?php echo cutString($item->message, 100, '...') ?></p>
                                            </div>
                                        </div>
                                    </div>
                                <?php
                                }
                            }else{
                                echo "<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>".$this->lang->line('No message')."</div>";
                            }
                            ?>
                        </div>
                        <div class="dashboard-pagination ajax-pagination text-center col-lg-12 col-md-12 col-sm-12 no-padding" data-target="#message_inbox" data-url="<?php echo site_url('buyer/ajaxGetMessageInbox')?>">
                            <?php if(isset($pagination_inbox)) echo $pagination_inbox;?>
                        </div>
                    </div>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding message-content tab-pane fade in" id="send">
                        <div id="message_send">

                            <?php
                            if($message_send->num_rows() > 0) {
                                foreach ($message_send->result() as $item) {
                                    ?>
                                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding item-mess">
                                        <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
                                            <div class="table-cell">
                                                <input type="checkbox" data-id="<?php echo $item->id; ?>">
                                            </div>
                                        </div>
                                        <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 no-padding">
                                            <a href="#" />
                                            <img src="<?php echo ( (is_file_exists($item->logo)) && ($item->logo != "")) ? uimage_url($item->logo) : image_default();?>" class="img-responsive" />
                                            </a>
                                        </div>
                                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                                            <div class="table-cell">
                                                <a href="#" ><?php echo $item->user_name ?></a>
                                                <p><?php echo dateAgo($item->created, 'd-m-Y') ?></p>
                                            </div>
                                        </div>
                                        <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7">
                                            <div class="table-cell">
                                                <span class="subject-message"><?php echo $item->subject ?></span>
                                                <p><?php echo cutString($item->message, 100, '...') ?></p>
                                            </div>
                                        </div>
                                    </div>
                                <?php
                                }
                            }else{
                                echo "<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>".$this->lang->line('No message')."</div>";
                            }
                            ?>
                        </div>
                        <div class="dashboard-pagination ajax-pagination text-center col-lg-12 col-md-12 col-sm-12 no-padding" data-target="#message_send" data-url="<?php echo site_url('buyer/ajaxGetMessageSend')?>">
                            <?php if(isset($pagination_send)) echo $pagination_send;?>
                        </div>
                    </div>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding message-content tab-pane fade in" id="archive">
                        <div id="message_send">

                            <?php
                            if($archive->num_rows() > 0) {
                                foreach ($archive->result() as $item) {
                                    ?>
                                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding item-mess">
                                        <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
                                            <div class="table-cell">
                                                <input type="checkbox" data-id="<?php echo $item->id; ?>">
                                            </div>
                                        </div>
                                        <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 no-padding">
                                            <a href="#" />
                                            <img src="<?php echo ( (is_file_exists($item->logo)) && ($item->logo != "")) ? uimage_url($item->logo) : image_default();?>" class="img-responsive" />
                                            </a>
                                        </div>
                                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                                            <div class="table-cell">
                                                <a href="#" ><?php echo $item->user_name ?></a>
                                                <p><?php echo dateAgo($item->created, 'd-m-Y') ?></p>
                                            </div>
                                        </div>
                                        <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7">
                                            <div class="table-cell">
                                                <span class="subject-message"><?php echo $item->subject ?></span>
                                                <p><?php echo cutString($item->message, 100, '...') ?></p>
                                            </div>
                                        </div>
                                    </div>
                                <?php
                                }
                            }else{
                                echo "<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>".$this->lang->line('No message')."</div>";
                            }
                            ?>
                        </div>
                        <div class="dashboard-pagination ajax-pagination text-center col-lg-12 col-md-12 col-sm-12 no-padding" data-target="#archive" data-url="<?php echo site_url('buyer/ajaxGetMessageArchive')?>">
                            <?php if(isset($pagination_archive)) echo $pagination_archive;?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $this->load->view('footer'); ?>

<script type="application/javascript">
    $(document).ready(function () {

    });
</script>